﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Nes.Core.PPUS;

namespace Nes.Core
{
    public class DMA
    {
        private CPU cpu;
        private PPU ppu;
        public DMA(CPU cpu, PPU ppu) 
        {
            this.cpu = cpu;
            this.ppu = ppu;
        }

        public void Copy(Int32 address)
        {
            var data = new Byte[256];
            for(var offset = 0; offset < 256; offset++)
            {
                data[offset] = cpu.Bus.ReadByte(address + offset);
            }
            ppu.DMACopy(data);
            cpu.SetSuspendCycles();
        }
    }
}
